package com.wuseguang.springcloud.controller;


import com.wuseguang.springcloud.Filter.RequestParameterWrapper;
import com.wuseguang.springcloud.entity.MeMoralEducationRecord;
import com.wuseguang.springcloud.service.MeMoralEducationRecordService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 德育-班级德育记录 前端控制器
 * </p>
 *
 * @author 
 * @since 2020-06-28
 */
@RestController
@RequestMapping("/jurisdiction")
public class MeMoralEducationRecordController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private MeMoralEducationRecordService meMoralEducationRecordServiceImpl;

    /**
     * 添加班级德育记录
     * @param request
     * @param meMoralEducationRecord
     * @return
     */
    @RequestMapping("/addMeMoralEducationRecord")
    public Result addMeMoralEducationRecord(RequestParameterWrapper request,
                                            MeMoralEducationRecord meMoralEducationRecord){
        logger.info("添加班级德育记录");
        //学校id
        String schoolId = request.getParam("schoolId");
        String teacherName = request.getParam("teacherName");
        meMoralEducationRecord.setSchoolId(Integer.valueOf(schoolId));
        meMoralEducationRecord.setTeacherName(teacherName);
        return  meMoralEducationRecordServiceImpl.addMeMoralEducationRecord(meMoralEducationRecord);
    }

    /**
     * 查询班级德育记录
     * @param request
     * @param findType 0本周,1上周,2本月,3自定义
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @param classId 班级id
     * @param indexNo 页码
     * @param rows 每页显示数量
     * @return
     */
    @RequestMapping("/findMeMoralEducationRecord")
    public Result findMeMoralEducationRecord(RequestParameterWrapper request,
                                              @RequestParam(value = "findType", required = false, defaultValue = "0") Integer findType,
                                              @RequestParam(value = "startTime", required = false) String startTime,
                                              @RequestParam(value = "endTime", required = false) String endTime,
                                              @RequestParam(value = "classId", required = false) String classId,
                                              @RequestParam(value = "indexNo", required = false, defaultValue = "1") Integer indexNo,
                                              @RequestParam(value = "rows", required = false, defaultValue = "20") Integer rows){
        logger.info("查询班级德育记录");
        //学校id
        String schoolId = request.getParam("schoolId");
        return  meMoralEducationRecordServiceImpl.findMeMoralEducationRecord(schoolId,findType,startTime,endTime,classId,indexNo,rows);
    }

    /**
     * 删除班级德育记录
     * @param request
     * @param id 德育记录id
     * @return
     */
    @RequestMapping("/deleteMeMoralEducationRecord")
    public Result deleteMeMoralEducationRecord(RequestParameterWrapper request,
                                               @RequestParam(value = "id") Integer id){
        logger.info("删除班级德育记录");
        return  meMoralEducationRecordServiceImpl.deleteMeMoralEducationRecord(id);
    }

}

